package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

/**
 *缓冲字符流---最常用的读写字符串的流
 * 是一对高级流，并且是字符流
 * 内部维护一个默认8kb(8192)长度的char数组,还是以块读写形式读写字符以提高读写效率
 * BufferedWrite和BufferedReader
 *
 * printWriter:按行写入数据
 */
public class PWDemo {
    public static void main(String[] args) throws IOException {
        //最常用写入字符串方式:
        //底层连接了BufferedWriter,连接了OutputStreamWriter,连接了FileOutputStream
        PrintWriter pw = new PrintWriter("pw.txt");
        pw.println("啦啦啦，你是说角度上考虑苏东坡i");
        pw.println("金属拉丝颇为都");
        System.out.println("写出完毕");
        pw.close();



        /*
        FileOutputStream fos = new FileOutputStream("pw.txt");//文件流(低级流)
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);//转换流(高级流)
        BufferedWriter bw = new BufferedWriter(osw);//缓冲字符流(高级流)
        PrintWriter pw = new PrintWriter(bw);
        pw.write("啦啦啦，你是说角度上考虑苏东坡i");
        pw.write("金属拉丝颇为都");
        System.out.println("完毕");
        pw.close();//先调用flush()冲水
         */



    }
}
